<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
       function* generator_test() { console.log('test1'); yield 'niuge'; console.log('test2'); yield 'kaige'; }
       // 生成遍历器对象 
       let g_t = generator_test(); 
       console.log(g_t);
       let next1 = g_t.next(); 
       console.log(next1); 
       let next2 = g_t.next(); 
       console.log(next2); 
       // 对象的Symbol.iterator属性; let SyIterable = {}; SyIterable[Symbol.iterator] = function* () { yield 1; yield 2; yield 4; };for (let i of SyIterable) { console.log(i); }let obj = [...SyIterable]; console.log(obj);
    </script>
</body>
</html>